package adger.me.yili.view.impl;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import adger.me.yili.R;

public class OrderDetailActivity extends AppCompatActivity  {
    private TextView mUsername;
    private TextView mMember;
    private TextView mOrderNumber;
    private TextView mOrderNum;
    private TextView mPhone;
    private TextView mAddresss;
    private TextView mCountMoney;
    private TextView mGetOrder;
    private TextView mCancelOrder;
    private TextView title;
    private ImageView back;
    private TextView backText;


//    private DetailPresenter mDetailPresenter;
//    private int orderId;
//    private OrdersTable ordersBean;
//    private List<OrdersTable.Orders> orders;
//    private List<OrdersTable.OrderLines> orderLines;
//    private OrderDetailAdapter mAdapter;
//    private RecyclerView recyclerView;
//    private LinearLayoutManager mLinearLayoutManager;
//    private JSONObject mOrderList = null;
//    private ACache mACache;
//    float result = 0;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_detail);
    }
//        mDetailPresenter = new DetailPresenter(this);
//
//        mUsername = (TextView) findViewById(R.id.detail_username);
//        mMember = (TextView) findViewById(R.id.detail_number);
//        mOrderNum = (TextView) findViewById(R.id.detail_count);
//        mOrderNumber = (TextView) findViewById(R.id.detail_order_number);
//        mPhone = (TextView) findViewById(R.id.detail_phone);
//        mAddresss = (TextView) findViewById(R.id.detail_address);
//        mCountMoney = (TextView) findViewById(R.id.detail_com_allcountmoney);
//        mGetOrder = (TextView) findViewById(R.id.get_order);
//        mCancelOrder = (TextView) findViewById(R.id.cancel_order);
//        title = (TextView) findViewById(R.id.title);
//        backText = (TextView) findViewById(R.id.back_text);
//        back = (ImageView) findViewById(R.id.back);
//
//        backText.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent = new Intent();
//                intent.setClass(getApplication(), OrderActivity.class);
//                startActivity(intent);
//                finish();
//            }
//        });
//        back.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent = new Intent();
//                intent.setClass(getApplication(), OrderActivity.class);
//                startActivity(intent);
//                finish();
//            }
//        });
//
//        recyclerView = (RecyclerView) findViewById(R.id.order_detail_list);
//        mACache = ACache.get(this);
//
//        Bundle bundle = getIntent().getExtras();
//        if (bundle.getString("order_id") != null) {
//            orderId = Integer.parseInt(bundle.getString("order_id"));
//
//            loadOrderDetail();
//        }
//    }
//
//    @Override
//    public void loadOrderDetail() {
//
//        if (orderId > 0) {
//            ordersBean = mDetailPresenter.loadDetail();
//            orders = ordersBean.orders;
//            mOrderNum.setText(String.valueOf(ordersBean.group_no));
//
//            JSONArray data = new JSONArray();
//            for (int i = 0; i < orders.size(); i++) {
//                if (orderId == Integer.parseInt(orders.get(i).id)) {
//                    data.put(orders.get(i));
//                    mUsername.setText(orders.get(i).user);
//                    mMember.setText(orders.get(i).user_sn);
//                    mOrderNumber.setText(orders.get(i).id);
//                    mPhone.setText(orders.get(i).telephone);
//                    mAddresss.setText(orders.get(i).address);
//
//                    // 组装数据
//                    orderLines = new ArrayList<>();
//                    if (orders.size() > 0) {
//                        for (int j = 0; j < orders.get(i).order_lines.size(); j++) {
//                            orderLines.add(orders.get(i).order_lines.get(j));
//                        }
//                    }
//                    // 计算总价
//                    for (int k = 0; k < orderLines.size(); k++) {
//                        result += orderLines.get(k).price * orderLines.get(k).quantity;
//                    }
//                    title.setText(orders.get(i).user + "的订单详情");
//                    mCountMoney.setText("合计     " + String.valueOf(String.format("%.2f", result)));
//                    // 写入缓存
//                    mOrderList = mDetailPresenter.initOrderDatas(orders.get(i).user, orders.get(i).user_sn, orders.get(i).id, ordersBean.group_id, orders.get(i).telephone, orders.get(i).address);
//                }
//            }
//            loadOrders();
//        }
//    }
//
//    @Override
//    public void loadOrders() {
////        mAdapter = new OrderDetailAdapter(this, orderLines, mCountMoney, result, mOrderList, mGetOrder, mCancelOrder);
////        // 设置RecycleView的布局管理
////        mLinearLayoutManager = new OrderLayoutManager(this);
////        recyclerView.setLayoutManager(mLinearLayoutManager);
////
////        //设置RecycleView的Item间的分割线
////        recyclerView.setItemAnimator(new DefaultItemAnimator());
////        recyclerView.setAdapter(mAdapter);
//    }
//
//    @Override
//    public void editOrderDetail() {
//
//    }


}
